import Vue from "vue"
import Router from "vue-router"
import Login from "./views/login.vue"
import Admin from "./views/admin.vue"
import Welcome from "./views/admin/welcome.vue" 
import Chapter from "./views/admin/chapter.vue"

Vue.use(Router);

// const originalPush = VueRouter.prototype.push
//    VueRouter.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }


export default new Router({
    mode: "history",
    base: process.env.BASE_URL,
    routes: [{
        path: "*",
        redirect: "/login",
    }, {
        path: "",
        redirect: "/login",
    }, {
        path: "/login",
        component: Login
    }, {
        path: "/",
        name: "admin",
        component: Admin,
        // meta: {
        //     loginRequire: true
        // },
        children: [{
            path: "welcome",
            name: "welcome",
            component: Welcome
        },{
            path: "business/chapter",
            name: "business/chapter",
            component: Chapter
        }]
    }]
})